import 'package:another_flutter_splash_screen/another_flutter_splash_screen.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vischat/core/annotations/getx_route_enhanced.dart';
import 'package:vischat/generated/route_table.dart';
import 'package:vischat/modules/splash/splash_binding.dart';
import 'package:vischat/modules/splash/splash_controller.dart';

@GetXRoute('/splash', binding: SplashBinding)
class SplashPage extends GetView<SplashController> {
  const SplashPage({super.key});

  @override
  Widget build(BuildContext context) {
    return FlutterSplashScreen(
      backgroundColor: Colors.white,
      splashScreenBody: Image.asset(
        controller.launchImage,
        errorBuilder: (
          BuildContext context,
          Object error,
          StackTrace? stackTrace,
        ) {
          return Container();
        },
      ),
      asyncNavigationCallback: () async {
        await Future.delayed(Duration(seconds: controller.countdown));
        Get.offNamed(RouteTable.HOME);
      },
    );
  }
}
